#pragma once

#include "DLL.h"
#include <iostream>

namespace My {

/**
 * A real value, whose visible representation has certain number of digits after the decimal point.
 */
template <typename R, int D> 
class DLL_API Decimal {
public:
	Decimal(R value = 0) : m_Value(value) { }
public:
	operator R() const { return m_Value; }
	Decimal & operator = (R value) { m_Value = value; return * this; }
private:
	R m_Value;
};

template <typename R, int D> 
DLL_API inline std::ostream & operator << (std::ostream & out, const Decimal<R, D> & d)
{
	std::ios::fmtflags f = out.setf(std::ios::fixed, std::ios::floatfield);
	int pr = out.precision(D);
	out << R(d);
	out.precision(pr);
	out.flags(f);
	return out;
}

template <typename R, int D> 
inline DLL_API std::istream & operator >> (std::istream & in, Decimal<R, D> & d)
{
	R value;
	in >> value;
	d = value;
	return in;
}

} // My